﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Arcanum.Game.Client.Presentation.ViewModels;
using GalaSoft.MvvmLight.Messaging;

namespace Arcanum.Game.Client.Presentation.Views
{
    /// <summary>
    /// Interaction logic for ConsoleControl.xaml
    /// </summary>
    public partial class ConsoleControl : UserControl
    {
        public ConsoleControl()
        {
            InitializeComponent();
            // Sets releases console when window closes.
            Application.Current.MainWindow.Closed += this.OnWindowClosing;
        }

        public ConsoleViewModel ViewModel
        {
            get { return this.DataContext as ConsoleViewModel; }
            set { this.DataContext = value; }
        }

        private void OnWindowClosing(object o, EventArgs e)
        {
            this.ViewModel.Dispose();
        }

        private void InitializeViewModel(object sender, EventArgs e)
        {
            Messenger.Default.Send(new ConsoleViewArgs()
            {
                InputTextBox = this.inputTextBox,
                OutputTextBlock = this.outputTextBlock
            });
        }
    }
}
